package thread.threadmethod;


/**
 * setDaemon(), 设置一个线程为守护线程, 该线程不会单独执行, 当其他非守护线程都执行结束后, 自动退出.
 */
public class Demo03ThreadMethodsetDaemon {
    public static void main(String[] args) {
        Runnable runnable = new Runnable() {
            @Override
            public void run() {
                System.out.println("自定义线程:" + Thread.currentThread().getName());
            }
        };

        Thread thread01 = new Thread(runnable);
        Thread thread02 = new Thread(runnable);
        Thread thread03 = new Thread(runnable);
        thread01.setDaemon(true);
        thread01.start();
        thread02.start();
        thread03.start();

    }
}
